<!DOCTYPE html>
<html>
<head>
    <title>#{get 'title' /}</title>
    <meta charset="${_response_encoding}">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm.css">
    <!--如果你用到了拓展包中的组件，还需要引用下面两个-->
    <link rel="stylesheet" href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.css">
    <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/wxmain.css'}">
    <script type='text/javascript' src='//g.alicdn.com/sj/lib/zepto/zepto.js' charset='utf-8'></script>
    <script src="/public/sui/config.js"></script>
    <script src="/public/javascripts/mustache.min.js"></script>
</head>
<body>
<!-- page集合的容器，里面放多个平行的.page，其他.page作为内联页面由路由控制展示 -->
<div class="page-group">
    <!-- 单个page ,第一个.page默认被展示-->
    <div class="page">
        #{doLayout /}
    </div>
    <!-- popup, panel 等放在这里 -->
    <div class="panel-overlay"></div>
    <!-- Left Panel with Reveal effect -->
    <div class="panel panel-left panel-reveal">
        <div class="content-block">
            <p>用户信息</p>
            <!-- Click on link with "close-panel" class will close panel -->
            <p id="username"></p>
            <p id="mobile"></p>
            <p id="common"></p>
            <p><a href="#" class="close-panel button" id="logout">退出登录</a></p>
        </div>
    </div>
</div>
<script>
    $(function () {
        $.init()

        $(document).on('click','#logout',function () {
            localStorage.removeItem("user");
            location.href="login";
        });
    })
</script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm.js' charset='utf-8'></script>
<script type='text/javascript' src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.js' charset='utf-8'></script>
<script>
    $(function () {
        var user = localStorage.getItem("user");
        if(user){
            user = JSON.parse(user);
            if(user.data.user.username)
                $("#username").html("用户名:" +user.data.user.username);
            if(user.data.user.mobile)
                $("#mobile").html("手机号:" +user.data.user.mobile);
            if(user.data.user.common)
                $("#common").html("备注信息:" +user.data.user.common);
            var uid = user.data.user.id;
            var token = user.data.token;
            $.ajax({
                type:"POST",                      //请求类型
                url:"/apicontroller/isLogin",                 //URL
                data:{uid:uid,token:token},                  //传递的参数
                dataType:"json",                 //返回的数据类型
                success:function(data){          //data就是返回的json类型的数据
                    console.log(JSON.stringify(data));
                    if(data.code=="0"){
                        localStorage.setItem("user","");
                        location.href='/WxController/login';
                    }
                }
            });
        }else{
            location.href='/WxController/login';
        }
    });
</script>
</body>
</html>
